//package com.yy.config;
//
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
//import org.springframework.security.config.annotation.web.builders.HttpSecurity;
//import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
//import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
//import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
//
//import javax.sql.DataSource;
//
///**
// * @Author: yy
// * @Date 2021/11/19 19:20
// */
//@EnableWebSecurity
//public class SecurityConfig extends WebSecurityConfigurerAdapter {
//    //授权
//    @Override
//    protected void configure(HttpSecurity http) throws Exception {
//        //请求授权规则
//        http.authorizeRequests()
//                .antMatchers("/").permitAll()
//                .antMatchers("/getUserList").permitAll()
//                .antMatchers("/getDptList").hasRole("r001");
//
//        //没有权限默认转到登录（自带登录页），需要开启自己的登录页
//        http.formLogin();
//
//
//    //注销 开启注销 成功注销页面跳转
//        http.logout().logoutSuccessUrl("/");
//
//
//    //开启记住我 cookie
//        http.rememberMe();
//    }
//
//    //认证 PasswordEncoder 密码编码，加密 内存方式
////    @Override
////    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
////        auth.inMemoryAuthentication().passwordEncoder(new BCryptPasswordEncoder())
////                .withUser("tpj").password(new BCryptPasswordEncoder().encode("123456")).roles("r001")
////                .and()
////                .withUser("ok").password(new BCryptPasswordEncoder().encode("201610")).roles("r001");
////    }
//
//
//    //认证 PasswordEncoder 密码编码，加密 数据库方式
////    @Autowired
////    private DataSource dataSource;
////
////    @Override
////    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
////        auth.jdbcAuthentication()
////                .dataSource(dataSource)
////                .withDefaultSchema()
////                .withUser("tpj").password("123456").roles("r001")
////                .and()
////                .withUser("ok").password("201610").roles("r002");
////
////    }
//}
